package service

import "github.com/gogf/gf/v2/os/gcache"

type (
	IMycache interface {
		CacheSetAdapter()
	}
)

var (
	localMycache IMycache
)

func Mycache() IMycache {
	if localMycache == nil {
		panic("implement not found for interface IMycache, forgot register?")
	}
	return localMycache
}

func RegisterMycache(i IMycache) {
	localMycache = i
}

var cacheInstance *gcache.Cache

func GetCacheInstance() *gcache.Cache {
	if cacheInstance == nil {
		Mycache().CacheSetAdapter()
	}
	return cacheInstance
}
func SetCacheInstance(i *gcache.Cache) {
	cacheInstance = i
}
